﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="SearchByTag.aspx.vb" Inherits="Veterans.SearchByTag" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <p style="text-align: center;">
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <a href="SearchByTag.aspx?Tag=<%# Eval("Tag_Name") %>"><%# Eval("Tag_Name")%> </a>
        </ItemTemplate>
        <SeparatorTemplate> | </SeparatorTemplate>
    </asp:Repeater>
    </p>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
        SelectCommand="SELECT [Tag_Name] FROM [TBL_Tags]"></asp:SqlDataSource>


    <br />
    <hr />

    <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" 
        AutoGenerateColumns="False" Width="100%" AllowSorting="True" 
        CellPadding="4" ForeColor="#333333">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:BoundField DataField="T_type" HeaderText="Category" />
            <asp:HyperLinkField DataNavigateUrlFields="T_ID" 
                DataNavigateUrlFormatString="Details.aspx?D={0}" DataTextField="T_Title" 
                HeaderText="Subject" SortExpression="T_ID" >
            <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
            </asp:HyperLinkField>
            <asp:BoundField DataField="T_time" HeaderText="added Time" SortExpression="T_time" >
            <FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:BoundField DataField="T_Writer" HeaderText="Added by" 
                SortExpression="T_Writer" >
            <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:BoundField>
            <asp:ImageField DataImageUrlField="T_Picture" DataImageUrlFormatString="/Images/{0}" ControlStyle-CssClass="Thumbnail" HeaderText="Thumbnail" SortExpression="T_Picture">
                <ControlStyle CssClass="Thumbnail"></ControlStyle>
                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:ImageField>
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <EmptyDataTemplate>
            Click on the tag to search !!!
        </EmptyDataTemplate>
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
    ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
    SelectCommand="SELECT Distinct a.[T_ID], a.[T_Title], a.[T_Picture], a.[T_Text], a.[T_time], a.[T_Writer], a.[T_type] FROM [TBL_Topics] a, [TBL_TopicsTags] b, [TBL_Tags] c  where a.[T_ID] = b.[T_fkID] and b.[Tag_fkID] = c.[Tag_ID] and (c.[Tag_Name] = ?) ">
        <SelectParameters>
            <asp:QueryStringParameter Name="Tag" QueryStringField="Tag" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
        <br />


</asp:Content>
